//
//  ShangpinxiangqingView.m
//  OpenYooxi_IOS
//
//  Created by YeahYes on 15/3/17.
//  Copyright (c) 2015年 com.ivyvi.ee. All rights reserved.
//

#import "ShangpinxiangqingView.h"
#import "UIViewExt.h"

@implementation ShangpinxiangqingView{
    UILabel *name;
    UILabel *money;
    UIImageView *shangpinImg;
}

#pragma mark - init创建跟帖视图

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        self.userInteractionEnabled = YES;
        [self _createView];
        
    }
    return self;
    
}

#pragma mark - init里面的方法

- (void)_createView {
    UIView *xianview = [[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width/2, 0, 1,self.frame.size.height)];
    xianview.backgroundColor = [UIColor clearColor];
    [self addSubview:xianview];
    
    name = [[UILabel alloc] initWithFrame:CGRectMake(13, 5, kScreenWidth/4-13, 26)];
    name.font = [UIFont systemFontOfSize:10];
    name.numberOfLines = 0;
    name.textColor = [UIColor blackColor];
    name.userInteractionEnabled = YES;
    name.text = @"索尼Z3智享版收发";
    [self addSubview:name];
    
    money = [[UILabel alloc] initWithFrame:CGRectMake(13, 0, kScreenWidth/4-13, 26)];
    money.font = [UIFont systemFontOfSize:10];
    money.userInteractionEnabled = YES;
    money.numberOfLines = 0;
    money.top = name.bottom;
    money.textColor = UIColorFromRGB(0xBEBEBE);
    money.text = @"预约金：500元";
    [self addSubview:money];
    
    shangpinImg = [[UIImageView alloc] initWithFrame:CGRectMake((kScreenWidth/4-40)/2, 0, 40, 40)];
    shangpinImg.userInteractionEnabled = YES;
    shangpinImg.top = money.bottom+2;
    shangpinImg.image = [UIImage imageNamed:@"5__11"];
    [self addSubview:shangpinImg];
    
    
    UIButton *buttons = [UIButton buttonWithType:UIButtonTypeCustom];
    buttons.frame = CGRectMake(0, 5, self.frame.size.width, self.frame.size.height);
    buttons.backgroundColor = [UIColor clearColor];
    [buttons addTarget:self action:@selector(tuangouclick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:buttons];
    
    
    
    //字体加颜色
    NSMutableAttributedString *attrstring1 = [[NSMutableAttributedString alloc] initWithString:money.text];
    NSString *s1 = [money.text substringFromIndex:4];
    [attrstring1 addAttribute:NSForegroundColorAttributeName
                        value:UIColorFromRGB(0xF89D5E)
                        range:[money.text rangeOfString:s1]];
    money.attributedText = attrstring1;
}

- (void)tuangouclick:(UIButton *)button{
    NSLog(@"我们来了");
}

@end
